WITHDRAW_SUB_TYPE_DCT = {
    '0': {'name': "银行卡"},
    '1': {'name': "Justpay"}
}

WITHDRAW_STATUS_DCT = {
    2: {'name': '成功'},
    32: {'name': '失败返款'}
}


EVENT_RULES = {
    "aggs": {
        "groups": [
            {
                "group_name": "提现类型／提现通道",
                "field_id": "withdraw_sub_type",
                "is_keyword": False,
                "field_name": "提现类型",
                "sub_fields": [
                    {
                        "field_id": "withdraw_third_type",
                        "is_keyword": False,
                        "field_name": "提现通道"
                    },
                ]
            },
            {
                "group_name": "渠道",
                "field_id": "_chn",
                "is_keyword": True,
                "field_name": "渠道"
            }
        ],
        "values": [
            {
                "value_id": "withdraw_price",
                "value_name": "提现金额",
                "fmt": "\"%.2f\" % a",
                "adjust_amount": True,
            },
            {
                "value_id": "withdraw_real_price",
                "value_name": "实际提现金额",
                "value_type": "float",
                "fmt": "\"%.2f\" % a",
                "adjust_amount": True,
            },
            {
                "value_id": "withdraw_fee_price",
                "value_name": "提现手续金额",
                "value_expr": "withdraw_price - withdraw_real_price",
                "fmt": "\"%.2f\" % v",
                "adjust_amount": True,
            },
        ],
        "uv": {
            "field_id": "_user_id",
            "field_name": "投注人次"
        },
        "pv": {
            "field_name": "投注次数"
        }
    }
}


EVENT_CONFIG = {
    "event_id": "withdraw",
    "event_name": "提现分析",
    "values": {
        "_user_id": {
            "field_name": "用戶ID",
            "value_type": "long",
            "display_priority": 1
        },
        "sub_type": {
            "field_name": "提現類型",
            "value_type": "long",
            "enum": {
                "target_enum_dct": WITHDRAW_SUB_TYPE_DCT
            },
            "display_priority": 2
        },
        "third_type": {
            "field_name": "提現渠道",
            "value_type": "long",
            "required": False,
            "detail_invisible": True
        },
        "status": {
            "field_name": "提现状态",
            "value_type": "long",
            "enum": {
                "target_enum_dct": WITHDRAW_STATUS_DCT
            },
            "display_priority": 3
        },
        "price": {
            "field_name": "提现金额",
            "value_type": "float",
            "display_priority": 4
        },
        "real_price": {
            "field_name": "实际提现金额",
            "value_type": "float",
            "display_priority": 5
        },
        "risk_reason": {
            "field_name": "風控原因",
            "value_type": "string",
            "display_priority": 6
        },
        "_event_time": {
            "field_name": "提现完成时间",
            "value_type": "long",
            "display_priority": 7
        }
    },
    "rule": EVENT_RULES
}
